package com.highcom.mapper.manyToMany;

import com.highcom.bean.Student;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper {

    @Select("SELECT DISTINCT s.id,s.name,s.age FROM student s,stu_cr sc where sc.sid=s.id")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "age",property = "age"),
            @Result(
                    property = "courses",
                    javaType = List.class,
                    column = "id",//根据查询出来的classes表的id字段来查询student表
                    /*
                    many = @Many()一对多固定写法

                     */
                    many = @Many(select = "com.highcom.mapper.manyToMany.CourseMapper.selectById")
            )
    })
    public List<Student> selectAll();
}
